cmake_minimum_required(VERSION 3.15)

# googtest 1.14 need c++ 14
set(CMAKE_CXX_STANDARD 14)

Project (Framework LANGUAGES CXX)

# source
file(GLOB SOURCES
    ${CMAKE_CURRENT_SOURCE_DIR}/DOFHandler/*.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/Assembly/*.cpp)

add_library(${PROJECT_NAME} SHARED ${SOURCES})

# header files
target_include_directories(
  ${PROJECT_NAME}
  PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../../
  PRIVATE ${CMAKE_INSTALL_PREFIX}/include/)

import_eigen3 ()

import_metis(${PROJECT_NAME})

target_link_directories(${PROJECT_NAME} PRIVATE ${CMAKE_INSTALL_PREFIX}/lib)
target_link_libraries(${PROJECT_NAME} PRIVATE Logging Configuration Algebra DataStructure DBManager)

# add_macro: windows class Export
target_compile_definitions(${PROJECT_NAME} PRIVATE EXPORTING_Pre)


install(
  TARGETS ${PROJECT_NAME}
  ARCHIVE DESTINATION lib
  RUNTIME DESTINATION bin)

# Test subproject
if (SG_BUILD_UNIT_TEST)
    import_gtest() #gtest 侵入性测试
    add_subdirectory(test)
    add_definitions(-DUSE_TEST)
    add_definitions(-DSG_METIS)
endif()

install(DIRECTORY ${PROJECT_SOURCE_DIR}/Common/     DESTINATION include/SGFem/Pre/Common)
install(DIRECTORY ${PROJECT_SOURCE_DIR}/DOFHandler/ DESTINATION include/SGFem/Pre/DOFHandler FILES_MATCHING PATTERN "*.h" PATTERN "test" EXCLUDE)
install(DIRECTORY ${PROJECT_SOURCE_DIR}/Assembly/   DESTINATION include/SGFem/Pre/Assembly   FILES_MATCHING PATTERN "*.h" PATTERN "test" EXCLUDE)